package model

import "fmt"

type YMaterial struct {
	Id                    int64  `json:"id"`
	PastureId             int64  `json:"pastureId"`
	PastureIngredientId   string `json:"pastureIngredientId"`
	PastureIngredientName string `json:"pastureIngredientName"`
	YynIngredientId       string `json:"yynIngredientId"`
	YynIngredientName     string `json:"yynIngredientName"`
	CreatedAt             int64  `json:"createdAt"`
	UpdatedAt             int64  `json:"updatedAt"`
}

func (YMaterial) TableName() string {
	return "y_material"
}

type YMaterialSlice []*YMaterial

func (y YMaterialSlice) ToMap() map[string]*YMaterial {
	res := make(map[string]*YMaterial)
	for _, v := range y {
		key := fmt.Sprintf("%s%s", v.PastureIngredientId, v.PastureIngredientName)
		res[key] = v
	}
	return res
}
